package com.example.demo.mapper;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.bean.PageRes;
import com.example.demo.bean.SysJob;
import com.example.demo.dto.task.SysJobPageReqVO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface SysJobMapper extends BaseMapperX<SysJob> {

    default PageRes<SysJob> selectPage(SysJobPageReqVO reqVO){
        Page<SysJob> page = new Page<>(reqVO.getPageNo(), reqVO.getPageSize());
        return selectPageCommon(page,new QueryWrapper<SysJob>()
                .like(ObjectUtil.isNotNull(reqVO.getJobName()),"job_name",reqVO.getJobName())
                .like(ObjectUtil.isNotNull(reqVO.getJobGroup()),"job_group",reqVO.getJobGroup())
                .eq(ObjectUtil.isNotNull(reqVO.getStatus()),"status",reqVO.getStatus())
                .like(ObjectUtil.isNotNull(reqVO.getInvokeTarget()),"invoke_target",reqVO.getInvokeTarget())
        );
    }
}
